package com.zryc.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class OrderServiceImpl3ExceptionHandle{

    @SentinelResource(value = "message",fallback = "handle",blockHandler = "handleBlock")
    public static String handle(Throwable throwable){
            log.error("{}",throwable);
            return "ss程序出错了";
        }
        public static String handleBlock(BlockException blockException){
            log.error("{}",blockException);
            if (blockException instanceof FlowException){
                return "ss服务被限流了";
            }
            if (blockException instanceof DegradeException){
                return "ss服务被降级了";
            }
            return "static服务被限制访问了";
        }
}
